package lib.base;

@SuppressWarnings("serial")
public class EgoException extends Exception
{
	public static String SETUP_CALENDAR_FAILED = "setup calendar failed";
	public static String DELETE_HOLIDAY_FAILED = "delete holiday failed";
	public static String CUSTOMER_NOT_EXISTS = "customer does not exist";
	public static String WRONG_HOLIDAY_SYNTAX = "wrong holiday syntax";
	public static String NOT_AUTHORIZED = "your are not authorized to do this";
	public static String CONFIG_FILE_NOT_READABLE = "config file not found, not readable or incomplete";
	
	public EgoException() {
		super();
	}

	public EgoException(String arg0) {
		super(arg0);
	}

	public EgoException(Throwable arg0) {
		super(arg0);
	}

	public EgoException(String arg0, Throwable arg1) {
		super(arg0, arg1);
	}

	public String toString()
	{
		String msg = this.getMessage();
		String stack = "\nStack:\n";
		StackTraceElement[] s = null;
		if (this.getCause() == null)
		{
			s = this.getStackTrace();
		} else
		{
			msg += "\nCause: "+this.getCause().getMessage();
			s = this.getCause().getStackTrace();
		}
		for (int i=0;i<s.length;i++)
		{
			stack+=s[i].toString()+"\n";
		}
		
		return msg + stack;
	}
}
